package com.structure.adapter;

public class AdapterTest{
	public static void main(String[] args){
		String name = "战狼.mp3";
		Mp3Player player = null;
		String type = name.substring(name.indexOf(".") + 1);
		if (type.equalsIgnoreCase("mp3")) {
			player = new Mp3Player();
		} else if (type.equalsIgnoreCase("mp4")) {
			player = new Mp3Player(new MediaVideoAdapter());
		} else if (type.equalsIgnoreCase("jpg")) {
			player = new Mp3Player(new MediaImageAdapter());
		} else {
			System.out.println("暂时不支持此类型文件");
		}

		if (player != null)
			player.playMp3(name);
	}
}
